// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  devtools: { enabled: true },

  ssr: false,  // 禁用SSR，改为SPA模式

  modules: [
    '@pinia/nuxt',
    '@element-plus/nuxt',
    '@unocss/nuxt',
    '@nuxt/image'
  ],

  css: [
    '@unocss/reset/tailwind-compat.css',
    'element-plus/dist/index.css',
    'element-plus/theme-chalk/dark/css-vars.css',
    '~/assets/css/main.css'
  ],

  vite: {
    css: {
      preprocessorOptions: {
        scss: {
          api: 'modern-compiler'
        }
      }
    }
  },

  runtimeConfig: {
    public: {
      apiBase: process.env.NUXT_PUBLIC_API_BASE || 'http://localhost:8080',
      appTitle: process.env.NUXT_PUBLIC_APP_TITLE || '若依影视'
    }
  },

  nitro: {
    devProxy: {
      '/dev-api': {
        target: 'http://localhost:8080',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/dev-api/, '')
      }
    }
  },

  app: {
    head: {
      title: '若依影视',
      meta: [
        { charset: 'utf-8' },
        { name: 'viewport', content: 'width=device-width, initial-scale=1' },
        { name: 'description', content: '若依影视网站 - 在线观看最新电影电视剧' }
      ],
      link: [
        { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
      ]
    }
  },

  typescript: {
    shim: false
  },

  compatibilityDate: '2024-11-04'
})